package com.jmu.medicineknows.controller;

import com.jmu.medicineknows.dto.MenuQueryDto;
import com.jmu.medicineknows.entity.Menu;
import com.jmu.medicineknows.entity.Result;
import com.jmu.medicineknows.entity.User;
import com.jmu.medicineknows.service.MenuService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: JieZi
 * @Date: 2023/7/11 23:36
 * @Description:
 **/
@RestController
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    private MenuService menuService;

    @ApiOperation("获取所有菜单")
    @PostMapping("/list")
    public Result list(@RequestBody MenuQueryDto dto){
        return menuService.list(dto);
    }

    @ApiOperation("删除指定菜单")
    @GetMapping("/delete/{id}")
    public Result delete(@PathVariable("id") Long id){
        return menuService.delete(id);
    }

    @ApiOperation("更新/添加指定菜单")
    @PostMapping("/update")
    public Result update(@RequestBody Menu menu){
        return menuService.update(menu);
    }

    @ApiOperation("获取所有菜单id")
    @GetMapping("/ids")
    public Result ids(){
        return menuService.ids();
    }

}